
#include "mainscence.h"
#include "ui_mainscence.h"
#include<QPainter>
#include<QString>
#include<QDebug>
MainScence::MainScence(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainScence)
{
    ui->setupUi(this);
    setFixedSize(320,588);
    setWindowIcon(QIcon(":/new/coifilp/res/Coin0001.png"));
    setWindowTitle("翻金币main scene");
    connect(ui->atnquit,&QAction::triggered,this,&MainScence::close);
    myPushButton* mp=new myPushButton(":/new/coifilp/res/MenuSceneStartButton.png");
    mp->setParent(this);
    mp->move((this->width()-mp->width())*0.5,this->height()*0.9-mp->height());

    cs=new choosesence;
    connect(cs,&choosesence::backtomain,this,[=](){
        setGeometry(cs->geometry());
        cs->hide();
        this->show();

    });

    QSoundEffect* qs=new QSoundEffect(this);
    qs->setSource(QUrl::fromLocalFile(":/new/coifilp/res/TapButtonSound.wav"));
    connect(mp,&myPushButton::clicked,mp,[=](){
        mp->zoom1();
        mp->zoom2();
        QTimer::singleShot(500,mp,[=](){
            cs->setGeometry(this->geometry());
            this->hide();
            cs->show();
            qs->play();

        });
    });

}
void MainScence::paintEvent(QPaintEvent *event){
    QPainter* qp=new QPainter(this);
    QPixmap pixmap(":/new/coifilp/res/PlayLevelSceneBg.png");
    // 通过调用 scaled 函数将绘图设备的尺寸调整为窗口大小
    pixmap = pixmap.scaled(this->size());
    qp->drawPixmap(0,0,pixmap);
    pixmap.load(":/new/coifilp/res/Title.png");
//    pixmap = pixmap.scaled();
    qp->drawPixmap((this->width()-pixmap.width())*0.5,this->height()*0.07,pixmap);
    qp->end();
}
MainScence::~MainScence()
{
    delete ui;
}


